home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_39675.txt < prev    next >
Text File  |  1991-02-27  |  838b  |  27 lines

  1. -- card: 39675 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. Suppose a new instance variable is declared for the Person class: a character array of length 80 called 'name'.  Remember that array names are considered in C to represent the address of the first element of the array.  Therefore the following use of the standard string copy function may also cause program bombs:
  11.  
  12.     void   Person::set(void)
  13.     {
  14.         strcpy(name,"Jack Knapp");     /* may cause bombs in TC */
  15.     }
  16.     
  17. Instead, the programmer must assign each character one by one (or write a string-copy function which doesn't move memory):
  18.  
  19.     name[0] = 'J';
  20.     name[1] = 'a';
  21.              .
  22.              .
  23.  
  24.  
  25. -- part contents for background part 7
  26. ----- text -----
  27. 125